{% extends "base.html" %}
{% block base %}

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">陈勇志的接口测试平台</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">设置</a></li>
            <li><a href="/logout/">退出</a></li>
          </ul>
          <form class="navbar-form navbar-right">
            <input type="text" class="form-control" placeholder="搜索...">
          </form>
        </div>
      </div>
    </nav>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
          <ul class="nav nav-sidebar">
            <li class="active"><a href="/project/"><i class="glyphicon glyphicon-th-large">&nbsp;</i>项目管理 <span class="sr-only">current</span></a></li>
            <li><a href="/module/"><i class="glyphicon glyphicon-th">&nbsp;</i>模块管理</a></li>
          </ul>
          <ul class="nav nav-sidebar">
            <li><a href="/case_manage/">用例管理</a></li>
            <li><a href="/task_manage/">任务管理</a></li>
          </ul>
          <ul class="nav nav-sidebar">
            <li><a href="">mock server</a></li>
            <li><a href="">测试工具</a></li>
            <li><a href="">更多工具</a></li>
          </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          <!--项目列表-->
          {% if type == "list" %}
          <h4 class="sub-header">项目列表
            <button type="button" onclick="location.href='/project/add_project/'"
            class="btn btn-sm btn-primary" style="float:right">新建</button>
          </h4>
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                   <tr>
                  <th>id</th>
                  <th>名称</th>
                  <th>描述</th>
                  <th>状态</th>
                  <th>创建时间</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
              {% for each_data in all_data %}
                <tr>
                  <td>{{ each_data.id }}</td>
                  <td>{{ each_data.name }}</td>
                  <td>{{ each_data.description }}</td>
                  <td>
                    {% if each_data.status == True %}
                    <span>开启</span>
                    {% else %}
                    <span>关闭</span>
                    {% endif %}
                  </td>
                  <td>{{ each_data.create_time | date:"Y-m-d H:i:s" }}</td>
                  <td>
                    <!--编辑按钮-->
                    <a href="/project/edit_project/{{ each_data.id }}">
                    <i class="glyphicon glyphicon-pencil"></i>
                    </a>
                    <!--删除按钮-->
                    <a href="/project/del_project/{{ each_data.id }}">
                      <i style="padding-left:5px;" class="glyphicon glyphicon-trash"></i>
                    </a>
                  </td>
                </tr>
              {% endfor %}
              </tbody>
            </table>
          </div>
          {% endif %}
          <!--添加项目-->
          {% if type == "add" %}
            <h4 class="page-header" >新建项目</h4>
          <form action="/project/add_project/" method="post">
              <div class="form-group">
                <label for="input_project_name">项目名称</label>
                <input type="text" name="input_project_name" class="form-control" id="input_project_name" style="width: 500px;" placeholder="请输入项目名称...">
              <span style="color:red">{{ name_error }}</span>
              </div>
              <div class="form-group">
                <label for="input_description">项目描述</label>
                <textarea class="form-control" name="input_description" style="width: 500px;" rows="4" placeholder="请输入项目描述..."></textarea>
<!--                <input type="text" class="form-control" id="input_description" placeholder="请输入项目描述...">-->
              </div>
            <div class="form-row field-status">
              <div class="checkbox-row">
                 <input type="checkbox" name="status" value="1" id="id_status">
                  <label class="vCheckboxLabel" for="id_status">状态</label>
             </div>
            </div>
            {% csrf_token %}
              <button type="submit" class="btn btn-success">保存</button>
          </form>
          {% endif %}

          <!--编辑项目-->
          {% if type == "edit" %}
            <h4 class="page-header" >编辑项目</h4>
          <form action="/project/edit_project/{{ id }}/" method="post">
            <p>{{ project_form.as_p }}</p>
            {% csrf_token %}
            <input class="btn btn-success" type="submit" value="保存">
          </form>

          {% endif %}

        </div>
      </div>
    </div>

{% endblock %}
